use crate::data::cors::CorsOptions;
use rocket::Route;

static LIST_OPTIONS: CorsOptions = CorsOptions {
    allowed_methods: &["GET"],
    allowed_headers: &["Authorization"],
};

static STAT_OPTIONS: CorsOptions = CorsOptions {
    allowed_methods: &["GET"],
    allowed_headers: &["Authorization"],
};

static GEOIP_OPTIONS: CorsOptions = CorsOptions {
    allowed_methods: &["GET"],
    allowed_headers: &["Authorization"],
};

#[allow(unused_variables)]
#[options("/?<start>&<len>")]
async fn list_cors(start: u64, len: u16) -> &'static CorsOptions {
    &LIST_OPTIONS
}

#[allow(unused_variables)]
#[options("/stat?<start>&<end>&<type>")]
async fn stat_cors(start: String, end: String, r#type: String) -> &'static CorsOptions {
    &STAT_OPTIONS
}

#[allow(unused_variables)]
#[options("/geoip?<start>&<end>&<type>")]
async fn geoip_cors(start: String, end: String, r#type: String) -> &'static CorsOptions {
    &GEOIP_OPTIONS
}

pub fn route() -> Vec<Route> {
    routes![list_cors, stat_cors, geoip_cors]
}
